<html>
<head><meta charset="utf-8"><title>Prefer ra fixes to rustc · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html">Prefer ra fixes to rustc</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="240598487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240598487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ayomide Bamidele <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240598487">(May 28 2021 at 12:45)</a>:</h4>
<p>Hi, I wanted to have a go at <a href="https://github.com/rust-analyzer/rust-analyzer/issues/8645">https://github.com/rust-analyzer/rust-analyzer/issues/8645</a> (if no one is currently working on it). I have a question about the instructions provided. What exactly does "assign codes to our diagnostics to match rustc" mean? I found that <code>Assist</code> has <code>AssistId</code> - so would it be a case of having some sort of Map somewhere that maps AssistIds to rustc diagnostic codes?  Or am I looking at the wrong place</p>



<a name="240599101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240599101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240599101">(May 28 2021 at 12:50)</a>:</h4>
<p>That is referring to the E0123 codes rustc includes in most diagnostics</p>



<a name="240599150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240599150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240599150">(May 28 2021 at 12:50)</a>:</h4>
<p>I think we could just include those in each <code>Diagnostic</code> implementation?</p>



<a name="240600138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240600138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ayomide Bamidele <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240600138">(May 28 2021 at 12:59)</a>:</h4>
<p>Ah okay, I see. But when filtering out the error codes, I'm not sure how I would get from the <code>Fix</code> object in rust-analyzer/handler.rs to it's underlying error code to be able to filter them</p>



<a name="240600723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240600723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240600723">(May 28 2021 at 13:04)</a>:</h4>
<p>Originally each <code>Fix</code> comes from a diagnostic, the association is apparently lost when they're stored in <code>DiagnosticCollection</code>.</p>



<a name="240600751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240600751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240600751">(May 28 2021 at 13:04)</a>:</h4>
<p>You might be able to change <code>DiagnosticCollection</code> to keep this association</p>



<a name="240603550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240603550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ayomide Bamidele <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240603550">(May 28 2021 at 13:28)</a>:</h4>
<p>Okay I think I understand what to do now. However, in the implementations of ra <code>Diagnostic</code>s, the codes are already defined as text names like <code>no-such-field</code> instead of <code>E0123</code> etc. Would it be okay to change the appripriate ones to match rustc? Or keep them as they are and have logic to map them to a rustc code if appriopriate? I feel like the former would be cleaner, but not sure how much code relies on specifc <code>DiagnosticCode</code> values</p>



<a name="240603647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240603647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240603647">(May 28 2021 at 13:29)</a>:</h4>
<p>we want to keep our own codes, and just have a notion of what rustc diagnostics our own diagnostics correspond to</p>



<a name="240695681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240695681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ayomide Bamidele <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240695681">(May 29 2021 at 10:38)</a>:</h4>
<p>Would adding a DiagnosticCode field to the <code>Fix</code> struct be a good idea?</p>



<a name="240811536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240811536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240811536">(May 31 2021 at 09:32)</a>:</h4>
<p>Are you talking about this code?</p>
<p><a href="/user_uploads/4715/c7Mt4Y1cm-hCDB0Ky-4YXrr3/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/c7Mt4Y1cm-hCDB0Ky-4YXrr3/image.png" title="image.png"><img src="/user_uploads/4715/c7Mt4Y1cm-hCDB0Ky-4YXrr3/image.png"></a></div>



<a name="240811624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240811624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240811624">(May 31 2021 at 09:33)</a>:</h4>
<p>Short term, yeah, adding code to fix would work. Long term, this should be refactored according to the FIXMEs. Then, the code will be in the diagnostics, and the fix will be a part of diagnostic.</p>



<a name="240821455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240821455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ayomide Bamidele <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240821455">(May 31 2021 at 11:26)</a>:</h4>
<p>Refactoring seems like it would be a fun challenge,  though I can't seem to find an <code>ra_id</code> module in the repo or any mention of it other than the FIXME when I CTRL+SHIFT+F</p>



<a name="240832679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240832679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240832679">(May 31 2021 at 13:19)</a>:</h4>
<p>that shoud've been <code>ide::Diagnostics</code></p>



<a name="240832712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240832712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240832712">(May 31 2021 at 13:19)</a>:</h4>
<p><a href="https://github.com/matklad/rust-analyzer/blob/b44cfdc230e2750e3f53d210add4c1ecf88a0eec/crates/ide/src/diagnostics.rs#L33-L42">https://github.com/matklad/rust-analyzer/blob/b44cfdc230e2750e3f53d210add4c1ecf88a0eec/crates/ide/src/diagnostics.rs#L33-L42</a></p>
<p>This thing</p>



<a name="240832815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240832815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240832815">(May 31 2021 at 13:20)</a>:</h4>
<p>(if you are asking yourself "what's that <code>// pub name</code>", I ask myself the same question)</p>



<a name="240836568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Prefer%20ra%20fixes%20to%20rustc/near/240836568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Prefer.20ra.20fixes.20to.20rustc.html#240836568">(May 31 2021 at 13:56)</a>:</h4>
<p>Looks like it used to be the <code>code</code></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>